<template>
    <block v-if="scene == 1154">
    	<pyq-open-chunk></pyq-open-chunk>
    </block>
    <block v-else>
        <view class="page font14 col-3e bg-fff">
            <view class="topContent text-center top-25">
                <view class="fontBold fon15">您的新房摇号积分为</view>
                <view class="circleBox bg-theme-opacity">
                    <view class="pointsBox flex col-fff bg-theme">
                        <text class="points fontBold right-5">{{num}}</text>
                        <text class="top-3 font20">分</text>
                    </view>
                </view>
            </view>
            
            <view class="flex col-theme top-25 bottom-30">
                <button class="assessBtn" @click="reset">重新计算</button>
                <button class="assessBtn" @click="toHome">返回首页</button>
            </view>

			<view class="disclaimer left-15 right-15 font12 col-grey top-20">免责声明：以上测算数据仅供参考，部分三类人群不适用此购房积分计算，具体请以政府公示为准</view>

			<up-gap height="40"></up-gap>
        </view>
    </block>
</template>

<script>
    import { mapState, mapActions } from 'pinia';
    import { useConfigStore, useIndexStore, useUserInfoStore } from '@/store/index';
	import { socialStatisticsAPI} from "@/common/api";
    export default {
    data() {
      return {
        num: 0,
      }
    },
    computed:{
        ...mapState(useUserInfoStore, ['userInfo']),
    	...mapState(useIndexStore, ['scene']),
    	...mapState(useConfigStore, ['puid']),
    },
    onLoad(options) {
      let that = this;
      this.num = options.totalPoints;
      //朋友圈进入小程序快照场景
      if(this.scene == 1154) return;
      
      uni.$check_and_login(function (){
        // that.getData()
      })
    },
    //#ifdef MP-WEIXIN
    onShareTimeline() {
      return {
        title: '新房认购分数查询',
        imageUrl: 'https://image.srea.org.cn/xcx/share-integral-query-image-sh.jpg',
      }
    },
    //#endif

    onShareAppMessage() {
      return {
        title: '新房摇号积分计算',
        path: `/pages/tools/integral-query/integral-query?puid=${this.userInfo.id}`
      }
    },
    methods: {
        ...mapActions(useIndexStore, ['setTabIndex']),
        //获取统计数据
        getData() {
            socialStatisticsAPI().then(res => {
                if (res.status === 0) {
                    let { points } = res.detail;
                    this.num = points;
                }else {
                    this.$common.msg(res.detail)
                }
            })
        },
        toHome() {
            this.setTabIndex(0);
            uni.switchTab({
                url: '/pages/tabBar/home/index'
            });
        },
        reset() {
            uni.redirectTo({
                url: `/pages/tools/integral-query/integral-query?puid=${this.puid}`
            });
        }
    }
}
</script>

<style scoped lang="scss">
	.page{
        line-height: 1;
        min-height: 100vh;
        overflow: hidden;
        padding: 0rpx 28rpx;
        .topContent{
            .circleBox{
                margin: 20rpx auto 0rpx auto;
                width: 310rpx;
                height: 310rpx;
                padding: 10rpx;
                border-radius: 50%;
                .pointsBox{
                    width: 300rpx;
                    height: 300rpx;
                    border-radius: 50%;
                    overflow: hidden;
                    .points{
                        font-size: 90rpx;
                    }
                }
            }
        }
		.assessBtn{
            width: calc(50% - 50rpx);
            color: $theme-color;
            &::after{
                border: none;
            }
		}
        .disclaimer{
            line-height: 1.5;
        }
	}
</style>
